package org.grow;

public class Tool {
//    简单的矩形碰撞检测
    boolean rectCollision(float redx, float redy, float bluex, float bluey, int redWidth, int redHeight, int blueWidth, int blueHeight) {
//        System.out.println( Math.abs(redx - bluex) );
//        System.out.println(redWidth / 2 + blueWidth / 2);
//        System.out.println( Math.abs(redy - bluey) < redHeight / 2 + blueHeight / 2);
        if (
                Math.abs(redx - bluex) < redWidth / 2 + blueWidth / 2
                        &&
                        Math.abs(redy - bluey) < redHeight / 2 + blueHeight / 2
        ) {
            return true;
        }
        return false;
    }
    boolean rectCollision(Character red,Character blue){
        return  rectCollision(red.x,red.y,blue.x,blue.y,red.w,red.h,blue.w,blue.h);
    }

}
